Objects to Unify Type Classes and GADTs

نویسندگان

  • S. Oliveira
  • Martin Sulzmann
چکیده

We propose an Haskell-like language with the goal of unifying type classes and generalized algebraic datatypes (GADTs) into a single class construct. We treat classes as first-class types and we use objects (instead of type class instances and data constructors) to define the values of those classes. We recover the ability to define functions by pattern matching by using sealed classes. The resulting language is simple and intuitive and it can be used to define, with similar convenience, the same programs that we would define in Haskell. Furthermore, unlike Haskell, dictionaries (or objects) can be explicitly (as well as implicitly) passed to functions and we can program in a simple object-oriented style directly.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Chapter 4 One Vote for Type Families in

Generalized Algebraic DataTypes (GADTs) allow programmers to capture invariants of their data structures through type annotations on data constructors. However, when working with GADTs, it is often difficult to concisely and precisely express the way data manipulations maintain those invariants. One can use GADTs or multi-parameter type classes to model relations on types, but the results are n...

متن کامل

Wobbly types: type inference for generalised algebraic data types

Generalised algebraic data types (GADTs), sometimes known as “guarded recursive data types” or “first-class phantom types”, are a simple but powerful generalisation of the data types of Haskell and ML. Recent works have given compelling examples of the utility of GADTs, although type inference is known to be difficult. It is time to pluck the fruit. Can GADTs be added to Haskell, without losing...

متن کامل

Chapter 4 One Vote for Type Families in Haskell !

Generalized Algebraic DataTypes (GADTs) allow programmers to capture important invariants of their data structures through type annotations on data constructors. However when working with GADTs, it is often difficult to concisely and precisely express the way complex data manipulations maintain those invariants. One can approach the problem in a few different ways, given the arsenal of GHC’s cu...

متن کامل

Wobbly types: type inference for generalised algebraic data

Generalised algebraic data types (GADTs), sometimes known as “guarded recursive data types” or “first-class phantom types”, are a simple but powerful generalisation of the data types of Haskell and ML. Recent works have given compelling examples of the utility of GADTs, although type inference is known to be difficult. It is time to pluck the fruit. Can GADTs be added to Haskell, without losing...

متن کامل

OutsideIn ( X ) Modular type inference with local assumptions 24 March 2011 Dimitrios

Advanced type system features, such as GADTs, type classes, and type families have proven to be invaluable language extensions for ensuring data invariants and program correctness among others. Unfortunately, they pose a tough problem for type inference, because they introduce local type assumptions. In this article we present a novel constraint-based type inference approach for local type assu...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2008